package com.huangyi.ack.listener;

import com.huangyi.ack.constants.Constants;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
public class RetryListener {
    @RabbitListener( queues = Constants.RETRY_QUEUE )
    public String retryAuto(Message message) {
        String msg = new String(message.getBody());
        long deliveryTag = message.getMessageProperties().getDeliveryTag();
        System.out.printf("消息：%s , coorelationId = %s\n", msg, deliveryTag);
//        int i = 1/0;
     return "returnAuto 消费端执行完毕";
    }

    @RabbitListener( queues = Constants.RETRY_QUEUE )
    public String retryManual(Message message) {
        String msg = new String(message.getBody());
        long deliveryTag = message.getMessageProperties().getDeliveryTag();
        System.out.printf("消息：%s , coorelationId = %s\n", msg, deliveryTag);
        return "returnManual 消费端执行完毕";
    }
}
